package jmine.tec.extensions.impl.services;

import jmine.tec.extensions.services.ExceptionRecordRest;
import jmine.tec.extensions.services.rs.ExceptionRecordRepresentation;
import jmine.tec.rpc.server.base.AbstractRestServiceImplementor;
import bancosys.tec.rtm.impl.exception.dao.ExceptionRecordDAO;
import bancosys.tec.rtm.impl.exception.domain.ExceptionRecord;

/**
 * Implementation for ExceptionRecordRest
 * 
 * @author marcio.canovas
 */
public class ExceptionRecordRestImplementor extends AbstractRestServiceImplementor implements ExceptionRecordRest {

    /**
     * {@inheritDoc}
     */
    public void persist(ExceptionRecordRepresentation er) {
        ExceptionRecordDAO erDAO = this.getDAOFactory().getDAOByClass(ExceptionRecordDAO.class);
        ExceptionRecord exceptionRecord = erDAO.createBean();
        exceptionRecord.setMensagem(er.getMensagem());
        exceptionRecord.setUser(er.getUser());
        exceptionRecord.setSystem(er.getSystem());
        exceptionRecord.setContext(er.getContext());
        exceptionRecord.setTimestamp(er.getTimestamp());
        exceptionRecord.setStack(er.getStack());
        exceptionRecord.getPersister().save();
    }

}